home *** CD-ROM | disk | FTP | other *** search
/ Enter 2003 January / EnterCD 01_2003.iso / Internet / CuteFTP 3.0 / cuteftppro.exe / Disk1 / data1.cab / Sample_Scripts / Basic_Scripts / tests.vbs < prev   
Encoding:
Text File  |  2002-11-04  |  5.6 KB  |  177 lines

  1. '=======================================================================
  2. '= File:  tests.vbs
  3. '= Notes: 
  4. '=   script to display use of many TE object methods and properties.
  5. '=======================================================================
  6.  
  7. Sub Test()
  8.     'Create standard Scripting Host Shell object
  9.     Set Shell = CreateObject("WScript.Shell")
  10.  
  11.     'Get name of of the user's desktop folder by invoking 
  12.     'a VB function, then assign it as the localfolder
  13.     strDesktop = Shell.SpecialFolders("Desktop")
  14.  
  15.     ' line break
  16.     strNL = (Chr(13) & Chr(10))
  17.  
  18.     Dim fserv
  19.     Set fserv = CreateObject("CuteFTPPro.TEConnection")
  20.     'fserv.UseProxy = "BOTH"
  21.  
  22.     fserv.Retries = 0
  23.  
  24.     'socks-proxy prompt
  25.     nUserChoice = MsgBox ("Use Socks and Proxy", vbYesNoCancel)
  26.     If nUserChoice = vbYes Then
  27.         socksInfo = InputBox("Enter sock info (leave empty or use url syntax: socks[4|5]://[name:pass@]host:port)", "SOCKS", "socks5://proxy:1080") 
  28.         proxyInfo = InputBox("Enter proxy info (leave empty or use url syntax: [http|ftp]://[name:pass@]host:port)", "PROXY", "http://proxy:8000") 
  29.         fserv.SocksInfo = socksInfo
  30.         fserv.ProxyInfo = proxyInfo
  31.     else
  32.         If nUserChoice = vbNo Then
  33.             fserv.SocksInfo = socksInfo
  34.             fserv.ProxyInfo = proxyInfo
  35.         End If
  36.     End If
  37.  
  38.     'show sock and proxy info
  39.     If Not nUserChoice = vbCancel Then
  40.         socksInfo2 = fserv.SocksInfo
  41.         proxyInfo2 = fserv.ProxyInfo
  42.         If socksInfo2 = "" Then
  43.             socksInfo2 = "none"
  44.         End If
  45.         If proxyInfo2 = "" Then
  46.             proxyInfo2 = "none"
  47.         End If
  48.         strMsg = "Socks(" & socksInfo2 & ") and Proxy(" & proxyInfo2 & ")"
  49.         MsgBox strMsg, vbOKOnly, "Connection's SOCKS/PROXY info"
  50.     End If
  51.  
  52.     'test 0 - connect, REST, COMB
  53.     If Not nUserChoice = vbCancel Then
  54.         nUserChoice = MsgBox ("[TEST 0] connect, REST, COMB", vbYesNoCancel)
  55.     End If
  56.     If nUserChoice = vbYes Then
  57.         strHost = "ftp.cuteftp.com"
  58.  
  59.         strHost = InputBox("Enter host", "CuteFTP Pro", strHost)
  60.  
  61.         fserv.Host = strHost
  62.         fserv.Protocol = "ftp"
  63.         fserv.Connect
  64.         nREST = fserv.RestSupport
  65.         nCOMB = fserv.CombSupport
  66.         MsgBox "REST support: " & nREST & ", COMB support: " & nCOMB
  67.     End If
  68.  
  69.     'test 1 - remote exists test
  70.     If Not nUserChoice = vbCancel Then
  71.         nUserChoice = MsgBox ("[TEST 1] RemoteExists", vbYesNoCancel)
  72.     End If
  73.     If nUserChoice = vbYes Then
  74.         strHost = "ftp.cuteftp.com"
  75.         strPath = "/pub/cuteftppro/cuteftppro.exe"
  76.  
  77.         strHost = InputBox("Enter host", "CuteFTP Pro", strHost)
  78.         strPath = InputBox("Enter remote path", "CuteFTP Pro", strPath)
  79.         fserv.Host = strHost
  80.         fserv.Protocol = "ftp"
  81.  
  82.         if fserv.RemoteExists(strPath) then
  83.             ftype = fserv.FileType
  84.             fsize = fserv.FileSize
  85.             fdate = fserv.FileTimeModified
  86.             MsgBox "Remote file info: type=" & ftype & ", size=" & fsize & ", date=" & fdate & strNL & "type: 1 - dir, 2 - file, 3 - link"
  87.         else
  88.             MsgBox "File not found: " & strPath
  89.         End If
  90.     End If
  91.  
  92.     'test 2 - ftp download test
  93.     If Not nUserChoice = vbCancel Then
  94.         nUserChoice = MsgBox ("[TEST2] FTP Download: ", vbYesNoCancel)
  95.     End If
  96.     If nUserChoice = vbYes Then
  97.         strHost = "ftp.cuteftp.com"
  98.         strPath = "/pub/cuteftppro/cuteftppro.exe"
  99.         strLocalPath = strDesktop & "\te_com_test\CutePRO_ftp.exe"
  100.  
  101.         strHost = InputBox("Enter host", "CuteFTP Pro", strHost)
  102.         strPath = InputBox("Enter remote path", "CuteFTP Pro", strPath)
  103.         strLocalPath = InputBox("Enter local path", "CuteFTP Pro", strLocalPath)
  104.  
  105.         fserv.Host = strHost
  106.         fserv.Protocol = "ftp"
  107.         fserv.Download strPath, strLocalPath
  108.     End If
  109.  
  110.     'test 3 - ftp download multiple test
  111.     If Not nUserChoice = vbCancel Then
  112.         nUserChoice = MsgBox ("[TEST3] FTP Download multiple", vbYesNoCancel)
  113.     End If
  114.     If nUserChoice = vbYes Then
  115.         strHost = "ftp.cuteftp.com"
  116.         strPath = "/pub/cuteftppro"
  117.         strLocalPath = strDesktop & "\te_com_test"
  118.         strWCard = "*.*"
  119.  
  120.         strHost = InputBox("Enter host", "CuteFTP Pro", strHost)
  121.         strPath = InputBox("Enter remote path", "CuteFTP Pro", strPath)
  122.         strLocalPath = InputBox("Enter local path", "CuteFTP Pro", strLocalPath)
  123.         strWCard = InputBox("Enter name", "CuteFTP Pro", strWCard)
  124.  
  125.         fserv.Host = strHost
  126.         fserv.Protocol = "ftp"
  127.         fserv.RemoteFolder = strPath
  128.         fserv.LocalFolder = strLocalPath
  129.         fserv.Download strWCard, ""
  130.     End If
  131.  
  132.     'test 4 - http download test
  133.     If Not nUserChoice = vbCancel Then
  134.         nUserChoice = MsgBox ("[TEST4] HTTP Download", vbYesNoCancel)
  135.     End If
  136.     If nUserChoice = vbYes Then
  137.         strHost = "www.cuteftp.com"
  138.         strPath = "/index.html"
  139.         strLocalPath = strDesktop & "\te_com_test\http\index.txt"
  140.  
  141.         strHost = InputBox("Enter host", "CuteFTP Pro", strHost)
  142.         strPath = InputBox("Enter remote path", "CuteFTP Pro", strPath)
  143.         strLocalPath = InputBox("Enter local path", "CuteFTP Pro", strLocalPath)
  144.  
  145.         fserv.Host = strHost
  146.         fserv.Protocol = "http"
  147.         fserv.Download strPath, strLocalPath
  148.     End If
  149.  
  150.     'test 5 - ftp download test
  151.     If Not nUserChoice = vbCancel Then
  152.         nUserChoice = MsgBox ("[TEST5] FTP synchronize dir: ", vbYesNoCancel)
  153.     End If
  154.     If nUserChoice = vbYes Then
  155.         strHost = "ftp.microsoft.com"
  156.         strPath = "/solutions"
  157.         strLocalPath = strDesktop & "\te_com_test\sync"
  158.  
  159.         strHost = InputBox("Enter host", "CuteFTP Pro", strHost)
  160.         strPath = InputBox("Enter remote path", "CuteFTP Pro", strPath)
  161.         strLocalPath = InputBox("Enter local path", "CuteFTP Pro", strLocalPath)
  162.  
  163.         fserv.Protocol = "ftp"
  164.         fserv.Host = strHost
  165.         fserv.Synchronize strPath, strLocalPath, 1, 1
  166.     End If
  167.  
  168.     'MsgBox("Log: " & fserv.Log)
  169.  
  170. End Sub
  171.  
  172. '=======================================================================
  173. '= Main
  174. '=======================================================================
  175. Test()
  176. MsgBox("Done")
  177.